<?php
namespace app\admin\controller;

use app\common\controller\Common;
use app\admin\model\AuthRule;
use app\admin\model\Admin;
use think\facade\Config;
use app\admin\model\Menu;
use util\IpUtil;
class Base extends Common {
	public function __construct(){
		parent::__construct();

		if(!$this->check_admin_login())  {
			$this->redirect('admin/login/index');
		}	
		
		
		$auth = new AuthRule;
		$url = $auth->get_url();
		$menu_curr = $auth->get_url_menu_ids($url);

		if(!$auth->check_auth($url, $menu_curr[1])) {			
			$this->error("没有权限", url('admin/index/index'));			
		}

		// var_dump($menu_curr[0]);

		if(Menu::isCenterMenu($menu_curr[0])) {
			// 如果是中心节点,清除掉当前的服务器状态
			cookie("cur_server_id",null);
			$allmenus = Menu::getCenterMenu();	
		}  else {
			$allmenus = Menu::getGameMenu();
		}
		

		$uid = session('uid');
		$groupid = session('user.groupid');
		// var_dump($allmenus);
		$menus = $auth->getMenuList($groupid, $allmenus);

		$admin = new Admin;

		// 从中心服获取权限列表, 		
		$this->assign('menus',$menus);

		$this->assign("id_curr", $menu_curr[1]);
		$this->assign('menus_curr', $menu_curr);


	}
}